Skip to main content

Automatic Tuning

Achieving optimal performance in traditional FHE programs requires carefully balancing multiple factors, including the choice of FHE scheme (e.g., CKKS, BFV, BGV, etc.), FHE optimization passes, compiler optimization parameters (e.g., O3, O2, Os, etc.), and the FHE implementation library. Since different applications perform differently with specific FHE schemes, no universal algorithm can deliver optimal results across all scenarios. Additionally, optimization priorities vary: some scenarios emphasize strict memory constraints, others focus on reducing computation time, and some prioritize minimizing the target file size. Consequently, manual tuning is often necessary but comes with the following limitations:

  • Time-consuming and labor-intensive: The tuning process requires substantial time and effort from developers, often proving cumbersome with unpredictable outcomes.
  • Limited applicability: Due to the complexity of FHE programs, a tuning method that works well for one application may be ineffective or even harmful to others.

To address these challenges and ease the tuning burden on privacy application developers, Aegis has introduced Autotuner, an automated optimization tool.

autotuner

The main process is as follows:

  1. The compilation configuration file (compilation_config.json) is generated based on Aegis' implementation logic, supported FHE schemes, FHE implementation libraries, FHE optimization passes, and corresponding compilation parameters. This file includes all the compilation optimization options supported by Aegis. Currently, it can only be manually generated by Aegis developers. In future versions, Aegis will automatically generate this configuration file.

  2. The autotuner-driver module reads the configuration file, generates a set of compilation options, and then selects a set of parameters from this collection using a search algorithm.

  3. Aegis compiles the application source code using the selected compilation parameters to generate the final executable binary.

  4. Execute the binary to collect performance data. Based on the selected tuning objective (e.g., shortest execution time, least memory usage, etc.), compare the new performance parameters with those from previous iterations. If the new parameters perform better, update the metrics; otherwise, discard the results.

  5. After several iterations, Aegis autotuner will output the optimal binary and other related files based on the best performance metrics.